/*
* @Author: gaara  
* @Date: 2020-06-13 11:55:34  
*/

import { RawAsset } from "./RawAsset";
import _path from 'path'
import _fs from 'fs-extra'
import { UuidMgr } from "../UuidMgr";


/**
 * spine文件
 */
export class Skel extends RawAsset {


    scale: number

    textures: string[];

    constructor(path: string) {
        super(path);

        this.textures = [];
        this.scale = 1;
    }

    static version() {
        return "1.2.3";
    }

    static defaultType(): string[] {
        return [".skel"];
    }

    importPath() {

        let atlasPath = this.__path__.replace(".skel", ".atlas");
        let atlasStr = _fs.readFileSync(atlasPath, { encoding: "utf8" });
        let atlasArr = atlasStr.split('\n');
        let pngName = atlasArr[1];

        let parent = _path.dirname(this.__path__);
        let pngPath = _path.join(parent, pngName);
        let pngUUid = UuidMgr.getUUID(pngPath)
        this.textures = [pngUUid];
    }
}